<a href='https://github.com/angular/angular.js/edit/v1.6.x/src/ng/directive/script.js?message=docs(script)%3A%20describe%20your%20change...#L3' class='improve-docs btn btn-primary'><i class="glyphicon glyphicon-edit">&nbsp;</i>Improve this Doc</a>



<a href='https://github.com/angular/angular.js/tree/v1.6.6/src/ng/directive/script.js#L3' class='view-source pull-right btn btn-primary'>
  <i class="glyphicon glyphicon-zoom-in">&nbsp;</i>View Source
</a>


<header class="api-profile-header">
  <h1 class="api-profile-header-heading">script</h1>
  <ol class="api-profile-header-structure naked-list step-list">
    
    <li>
      - directive in module <a href="api/ng">ng</a>
    </li>
  </ol>
</header>





<div class="api-profile-description">
  <p>Load the content of a <code>&lt;script&gt;</code> element into <a href="api/ng/service/$templateCache"><code>$templateCache</code></a>, so that the
template can be used by <a href="api/ng/directive/ngInclude"><code>ngInclude</code></a>,
<a href="api/ngRoute/directive/ngView"><code>ngView</code></a>, or <a href="guide/directive">directives</a>. The type of the
<code>&lt;script&gt;</code> element must be specified as <code>text/ng-template</code>, and a cache name for the template must be
assigned through the element&#39;s <code>id</code>, which can then be used as a directive&#39;s <code>templateUrl</code>.</p>

</div>




<div>
  

  
  <h2>Directive Info</h2>
  <ul>
    
    <li>This directive executes at priority level 0.</li>
    
  </ul>

  
  <h2 id="usage">Usage</h2>
  <div class="usage">
  
    <ul>
    
      <li>as element:
      <pre><code>&lt;script&#10;  type=&quot;string&quot;&#10;  id=&quot;string&quot;&gt;&#10;...&#10;&lt;/script&gt;</code></pre>
      </li>
    
  </div>
  
<section class="api-section">
  <h3>Arguments</h3>

<table class="variables-matrix input-arguments">
  <thead>
    <tr>
      <th>Param</th>
      <th>Type</th>
      <th>Details</th>
    </tr>
  </thead>
  <tbody>
    
    <tr>
      <td>
        type
        
        
      </td>
      <td>
        <a href="" class="label type-hint type-hint-string">string</a>
      </td>
      <td>
        <p>Must be set to <code>&#39;text/ng-template&#39;</code>.</p>

        
      </td>
    </tr>
    
    <tr>
      <td>
        id
        
        
      </td>
      <td>
        <a href="" class="label type-hint type-hint-string">string</a>
      </td>
      <td>
        <p>Cache name of the template.</p>

        
      </td>
    </tr>
    
  </tbody>
</table>

</section>
  

  
  <h2 id="example">Examples</h2><p>

<div>
  <plnkr-opener example-path="examples/example-script-tag"></plnkr-opener>

  <div class="runnable-example"
      path="examples/example-script-tag"
      name="script-tag">

  
    <div class="runnable-example-file" 
      name="index.html"
      language="html"
      type="html">
      <pre><code>&lt;script type=&quot;text/ng-template&quot; id=&quot;/tpl.html&quot;&gt;&#10;  Content of the template.&#10;&lt;/script&gt;&#10;&#10;&lt;a ng-click=&quot;currentTpl=&#39;/tpl.html&#39;&quot; id=&quot;tpl-link&quot;&gt;Load inlined template&lt;/a&gt;&#10;&lt;div id=&quot;tpl-content&quot; ng-include src=&quot;currentTpl&quot;&gt;&lt;/div&gt;</code></pre>
    </div>
  
    <div class="runnable-example-file" 
      name="protractor.js"
      type="protractor"
      language="js">
      <pre><code>it(&#39;should load template defined inside script tag&#39;, function() {&#10;  element(by.css(&#39;#tpl-link&#39;)).click();&#10;  expect(element(by.css(&#39;#tpl-content&#39;)).getText()).toMatch(/Content of the template/);&#10;});</code></pre>
    </div>
  

    <iframe class="runnable-example-frame" ng-src="{{getExampleIndex('examples/example-script-tag')}}" name="example-script-tag"></iframe>
  </div>
</div>


</p>

</div>


